package com.cn.mobileproject.activity.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

import com.cn.mobileproject.R;
import com.cn.mobileproject.data.GlobalValue;
import com.cn.mobileproject.data.SystemParams;
import com.cn.mobileproject.manager.TaskManager;
import com.cn.mobileproject.view.adapter.MyTaskAdapter;
import com.net.http.HttpException;

@SuppressLint("ValidFragment")
public class SuperviseTaskFragment extends TaskFragment {

	public SuperviseTaskFragment(){
		super();
	}
	
	public SuperviseTaskFragment(boolean check){
		super(check);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		return super.onCreateView(inflater, container, savedInstanceState);
	}
	
	protected void initComponent(){
		super.initComponent();
		adapter.setList(GlobalValue.getInstance().getSuperviseInstructs());
		adapter.notifyDataSetChanged();
		type = 3;
	}
	
	protected void initEvent(){
		super.initEvent();
	}
	
	
	@Override
	public void initInstructData() {
		super.initInstructData();
		if(GlobalValue.getInstance().getSuperviseInstructs()!=null)GlobalValue.getInstance().getSuperviseInstructs().clear();
		total = TaskManager.getInstance().initSuperviseInstruct(GlobalValue.getInstance().getSuperviseInstructs(), pageNo, PAGESIZE);
		if(GlobalValue.getInstance().getSuperviseInstructs()!=null)start = GlobalValue.getInstance().getSuperviseInstructs().size();
	}

	@Override
	public void setAdapterList() {
		super.setAdapterList();
		adapter.setList(GlobalValue.getInstance().getSuperviseInstructs());
		adapter.notifyDataSetChanged();
	}

	@Override
	protected void onSearchSuccess() {
		adapter.setList(GlobalValue.getInstance().getSuperviseInstructs());
		adapter.notifyDataSetChanged();
	}

	@Override
	protected void searchNextPageByCom() throws HttpException {
		pageNo++;
		total = TaskManager.getInstance().initSuperviseInstruct(GlobalValue.getInstance().getSuperviseInstructs(), pageNo, PAGESIZE);
		if(GlobalValue.getInstance().getSuperviseInstructs()!=null)start = GlobalValue.getInstance().getSuperviseInstructs().size();
	}
	
	public void doJob(){
		if(SystemParams.loadSuperviseInstruct==0){
			doLoadTask();
		}
		else{
			mRefreshListView.onRefreshComplete();
		}
	}


	
}
